using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using QuanLyThuVien1.DTO;


namespace QuanLyThuVien1.DAO
{
    public class CNhaXuatBan
    {
        public void themNhaXuatBan(NHAXUATBAN nh)
        {
            OleDbConnection connect = KETNOI.taoKetNoi();
            string connecstr = "insert into NHAXUATBAN values('"+nh.MANXB +"','"+nh.TENNXB+"','"+nh.DIENTHOAI+"')";
            OleDbCommand command = new OleDbCommand(connecstr, connect);
            command.ExecuteNonQuery();
            connect.Close();
        }
        public void xoaNhaXuatBan(string m_maNXB)
        {
            OleDbConnection connect = KETNOI.taoKetNoi();
            string connecstr = "delete from NHAXUATBAN where maNXB = " + m_maNXB;
            OleDbCommand command = new OleDbCommand(connecstr, connect);
            command.ExecuteNonQuery();
            connect.Close();
        }
        public DataTable TimNXB(string maNXB)
        {
            OleDbConnection connect = KETNOI.taoKetNoi();
            string connecstr = "select * from where maNXB = " + maNXB ;
            OleDbCommand command = new OleDbCommand(connecstr, connect);
            DataTable d = new DataTable();
            OleDbDataAdapter Adapter = new OleDbDataAdapter(command);
            Adapter.Fill(d);
            connect.Close();
            return d;
        }
        public bool KiemTraNXB(string tenNXB)
        {
            DataTable d = new DataTable();
            OleDbConnection connect = KETNOI.taoKetNoi();
            string connecstr = "select * from NHAXUATBAN where maNXB = '" + tenNXB + "'";
            OleDbDataAdapter adapter = new OleDbDataAdapter(connecstr, connect);
            adapter.Fill(d);
            connect.Close();
            if (d.Rows.Count > 0)
                return true;
            return false;
        }
    }
}
